﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MDI
{
    public partial class MDI : Form
    {


        #region Initialize
       
        public MDI()
        {
            InitializeComponent();
        }

        #endregion


        #region Properties...
       
        //property to recieve a message from a child form
        private string childMessage;
        public string ChildMessage
        {
            get { return childMessage; }
            set { childMessage = value; }
        }

        #endregion


        #region Click Events...
        
        private void mnuOpen_Click(object sender, EventArgs e)
        {
            //if child form is already open set focus to the form
            foreach (Form frm in this.MdiChildren)
            {
                if (frm is ChildOne)
                {
                    frm.Focus();
                    return;
                }
            }

            //call the overrided constructor of the child form
            ChildOne child = new ChildOne(this);

            child.MessageFromParent = mnuMessageText.Text;
            child.MdiParent = this;
            child.Show();
        }
        #endregion


        #region Methods and functions...

        
        //methods to update the status label
        public void UpdateMessage()
        {
            lblStatusMessage.Text = ChildMessage;
        }

        public void UpdateMessage(string message)
        {
            lblStatusMessage.Text = message;
        }

        #endregion


    }
}
